﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TrainingWorkshop.MVPWebsite.User.Interface.Services;
using DataContracts;

namespace TrainingWorkshop.MVPWebsite.User.Services
{
    public class UserService:IUserService
    {

        ServiceAgent.ServiceAgent UserServiceAgent = new ServiceAgent.ServiceAgent();

        /// <summary>
        /// Save a New User
        /// </summary>
        /// <param name="userDTO"></param>
        /// <returns></returns>
        public bool AddNewUser(UserDTO userDTO)
        {
            return UserServiceAgent.ServiceClient.AddNewUser(userDTO);
        }

        /// <summary>
        /// Delete User
        /// </summary>
        /// <param name="userId"></param>
        public void DeleteUser(int userId)
        {
            UserServiceAgent.ServiceClient.DeleteUser(userId);
        }

        /// <summary>
        /// Update User
        /// </summary>
        /// <param name="userDTO"></param>
        public void UpdateUser(UserDTO userDTO)
        {
            UserServiceAgent.ServiceClient.UpdateUser(userDTO);
        }

        /// <summary>
        /// Get All User
        /// </summary>
        /// <returns></returns>
        public List<UserDTO> GetAllUser()
        {
            return UserServiceAgent.ServiceClient.GetAllUser();
        }

        /// <summary>
        /// Get All Department
        /// </summary>
        /// <returns></returns>
        public List<DepartmentDTO> GetAllDepartment()
        {
            return UserServiceAgent.ServiceClient.GetAllDepartment();
        }

        /// <summary>
        /// Get User by Current UserId
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public UserDTO GetUserById(int userId)
        {
            return UserServiceAgent.ServiceClient.GetUserById(userId);
        }

        /// <summary>
        /// Search User by Complex Conditions
        /// </summary>
        /// <param name="departmentId"></param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <returns></returns>
        public List<UserDTO> SearchUser(int departmentId, string firstName, string lastName)
        {
            return UserServiceAgent.ServiceClient.SearchUser(departmentId, firstName, lastName);
        }

        /// <summary>
        /// Get All User Role
        /// </summary>
        /// <returns></returns>
        public List<RoleDTO> GetAllUserRole()
        {
            return UserServiceAgent.ServiceClient.GetAllUserRole();
        }
    }
}
